#include "proxy/conn/flowinstance.h"

namespace proxy{

  //int64_t FlowInstance::all_up_flow_ = 0;
  int FlowInstance::all_down_flow_ = 0;

  FlowInstance::FlowInstance(bool is_connected)
    :up_flow_(0),
    down_flow_(0),
    is_connected_(is_connected){
  }

  void FlowInstance::AddUpFlow(int up_flow){
    boost::mutex::scoped_lock lock(up_flow_mutex_);
    up_flow_ = up_flow_ + up_flow;
    //all_up_flow_ += up_flow;
  }

  void FlowInstance::AddDownFlow(int down_flow){
    boost::mutex::scoped_lock lock(down_flow_mutex_);
    down_flow_ = down_flow_ + down_flow;
    all_down_flow_ += down_flow;
  }

  int FlowInstance::ResetDownFlow(){
    int flow = all_down_flow_;
    all_down_flow_ = 0;
    return flow;
  }
}